package com.adcc.ags.gms.gw.vo;

import com.adcc.ags.gms.core.vo.BaseVO;
import com.adcc.ags.gms.gw.entity.Traffic;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Date;

/**
 * Created by xuechao on 2016/9/5.
 */
public class TrafficVO extends BaseVO {

    private long id;

    // 报文存储时间
    private String dateTime;

    private String dateStart;

    private String dateEnd;

    private String msgType;

    // 发送方
    private String sender;

    // 接收方
    private String receiver;

    // 报文原文
    private String rawMsg;

    // 报文部分1
    private String part1;

    // 报文部分2
    private String part2;

    // 报文部分3
    private String part3;

    // 报文部分4
    private String part4;

    // 报文部分5
    private String part5;

    // 消息ID
    private String msgId;

    // 出错BGS用户ID
    private String errorUser_id;

    // 错误代码 ---1001消息验证异常代码，2001消息过滤异常代码，3001发送下行报文异常代码, 4001发送上行报文异常代码，5001发送地地报文异常代码
    private String error_code;

    public String getDateStart() {
        return dateStart;
    }

    public void setDateStart(String dateStart) {
        this.dateStart = dateStart;
    }

    public String getDateEnd() {
        return dateEnd;
    }

    public void setDateEnd(String dateEnd) {
        this.dateEnd = dateEnd;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getError_code() {
        return error_code;
    }

    public void setError_code(String error_code) {
        this.error_code = error_code;
    }

    public String getDateTime() {
        return dateTime;
    }

    public void setDateTime(String dateTime) {
        this.dateTime = dateTime;
    }

    public String getMsgType() {
        return msgType;
    }

    public void setMsgType(String msgType) {
        this.msgType = msgType;
    }

    public String getSender() {
        return sender;
    }

    public void setSender(String sender) {
        this.sender = sender;
    }

    public String getReceiver() {
        return receiver;
    }

    public void setReceiver(String receiver) {
        this.receiver = receiver;
    }

    public String getRawMsg() {
        return rawMsg;
    }

    public void setRawMsg(String rawMsg) {
        this.rawMsg = rawMsg;
    }

    public String getPart1() {
        return part1;
    }

    public void setPart1(String part1) {
        this.part1 = part1;
    }

    public String getPart2() {
        return part2;
    }

    public void setPart2(String part2) {
        this.part2 = part2;
    }

    public String getPart3() {
        return part3;
    }

    public void setPart3(String part3) {
        this.part3 = part3;
    }

    public String getPart4() {
        return part4;
    }

    public void setPart4(String part4) {
        this.part4 = part4;
    }

    public String getPart5() {
        return part5;
    }

    public void setPart5(String part5) {
        this.part5 = part5;
    }

    public String getMsgId() {
        return msgId;
    }

    public void setMsgId(String msgId) {
        this.msgId = msgId;
    }

    public String getErrorUser_id() {
        return errorUser_id;
    }

    public void setErrorUser_id(String errorUser_id) {
        this.errorUser_id = errorUser_id;
    }

    @Override
    public String toJson() throws JsonProcessingException {
        return new ObjectMapper().writeValueAsString(this);
    }

    @Override
    public Traffic toEntity() {
        Traffic traffic = new Traffic();
        traffic.setId(this.id);
        traffic.setDateTime(new Date());
        traffic.setError_code(this.error_code);
        traffic.setErrorUser_id(this.errorUser_id);
        traffic.setMsgId(this.msgId);
        traffic.setMsgType(this.msgType);
        traffic.setPart1(this.part1);
        traffic.setPart2(this.part2);
        traffic.setPart3(this.part3);
        traffic.setPart4(this.part4);
        traffic.setPart5(this.part5);
        traffic.setRawMsg(this.rawMsg);
        traffic.setReceiver(this.receiver);
        traffic.setSender(this.sender);
        return traffic;
    }
}
